package com.copractice.bl.tags;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Data transfer object which contains info about particular area for particular user:
 * <ul>
 *  <li>id</li>
 *  <li>name</li>
 *  <li>number of question of this area</li>
 *  <li>learning score</li>
 *  <li>teaching score</li>
 * </ul>
 * 
 * @author Dmitry Churbanov (dmitry.churbanov@gmail.com)
 * @version 1.0 04/07/2009
 */
public class TagsInfo {

    private Long   id;
    private String name;
    private Long   amountOfQuestions;
    private Long   learningScore;
    private Long   teachingScore;

    public TagsInfo(Long id, String name, Long amountOfQuestions) {
        this.id = id;
        this.name = name;
        this.amountOfQuestions = amountOfQuestions;
    }

    public TagsInfo(Long id, String name, int amountOfQuestions) {
        this(id, name, new Long(amountOfQuestions));
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getAmountOfQuestions() {
        return amountOfQuestions;
    }

    public void setAmountOfQuestions(Long amountOfQuestions) {
        this.amountOfQuestions = amountOfQuestions;
    }

    public Long getLearningScore() {
        return learningScore;
    }

    public void setLearningScore(Long learningScore) {
        this.learningScore = learningScore;
    }

    public Long getTeachingScore() {
        return teachingScore;
    }

    public void setTeachingScore(Long teachingScore) {
        this.teachingScore = teachingScore;
    }

    /**
     * Sets learning and teaching score for current area. If one of the score
     * should not be changed or set, null should be passed.
     * 
     * @param learning
     *            learning score to set
     * @param teaching
     *            teaching score to set
     * @return instance of <code>AreaInfo</code> class with changed learning
     *         and(or) teaching score.
     */
    public TagsInfo setScore(Long learning, Long teaching) {
        if (learning != null) {
            setLearningScore(learning);
        }
        if (teaching != null) {
            setTeachingScore(teaching);
        }

        return this;
    }

    /**
     * Returns a hash code for this <code>AreaInfo</code>.
     * 
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 31).append(getId()).append(getName()).append(getAmountOfQuestions())
                                          .append(getTeachingScore()).append(getLearningScore()).toHashCode();
    }

    /**
     * Returns a string representation of the entity.
     * 
     * @return a string representation of the entity.
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).append("id", getId()).append("Name", getName())
                                        .append("AmountOfQuestions", getAmountOfQuestions())
                                        .append("TeachingScore", getTeachingScore())
                                        .append("LearningScore", getLearningScore())
                                        .toString();
    }

}
